package com.dailyblue.java.spring.boot.redis.controller;

import lombok.extern.slf4j.Slf4j;
import org.springframework.data.redis.core.StringRedisTemplate;
import org.springframework.data.redis.core.ValueOperations;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.concurrent.TimeUnit;

@RestController
@RequestMapping("/string2")
@Slf4j
public class String2RedisController {
    @Resource
    private StringRedisTemplate stringRedisTemplate;

    @GetMapping("/a")
    public String a() {
        ValueOperations value = stringRedisTemplate.opsForValue();
        value.set("A", "aa");
        value.set("B", "bb");
        Object v1 = value.get("A");
        log.info("v1:{}", v1);
        value.set("B", "1", 1, TimeUnit.MILLISECONDS);
        return "a";
    }
}
